﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class member_Default : System.Web.UI.Page
{
	public string EnterpriseName = "";
    public string UserID = "";
    public string UserPower = "";
    public string Footer = "";
	
    protected void Page_Load(object sender, EventArgs e)
    {        
        if (!Init.islogin(ref UserID,ref EnterpriseName,ref UserPower))
        {
            Response.Redirect("/Login.aspx");
        }        
        if (!UserPower.Contains("Manager"))
        {
            Response.Write("你没有权限！");
            Response.End();
        }
        this.EnableViewState = false;
        Response.Write(Init.InitDefault());
        //head.Text=Init.GetInterIDList("/Template/HtmlHead.html");
       // MsSqlToMySql();
    }

    Common Init = new Common();

    protected void btnSave_Click(object sender, EventArgs e)
    {
    }
    /*
    MsSqlHelper mssql = new MsSqlHelper();
    MySqlHelper mysql = new MySqlHelper();
    public void MsSqlToMySql()
    {
        DataSet ds=mssql.ExecuteDs("select top 5 dwbh,danwbh,dwmch,isjh,isxs,zjm,lxr,lxrdh,dzhdh from mchk");
        DataList.DataSource = ds;
        DataList.DataKeyNames = new string[] { "dwbh" };//主键
        DataList.DataBind();
    }
    /// <summary>
    /// 保存按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string id= ((Control)sender).ID.ToString();
        msg.Text = id;
                 
        DataTable dt = new DataTable();
        switch(id)
        {
            case "ToDw":
                //单位资料
                dt = mssql.ExecuteDt("select dwbh,danwbh,left(rtrim(dwmch),250) as dwmch,isjh,isxs,zjm,lxr,lxrdh,left(rtrim(dzhdh),250) dzhdh from mchk order by dwbh");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sql = @"insert into mchk(dwbh,danwbh,dwmch,isjh,isxs,zjm,lxr,lxrdh,dzhdh)"
                        +"values"
                        + "('" + dt.Rows[i][0].ToString() + "','" + dt.Rows[i][1].ToString() + "','" + dt.Rows[i][2].ToString() + "','" + dt.Rows[i][3].ToString() + "','" + dt.Rows[i][4].ToString() + "','" + dt.Rows[i][5].ToString() + "','" + dt.Rows[i][6].ToString() + "','" + dt.Rows[i][7].ToString() + "','" + dt.Rows[i][8].ToString() + "')";
                    mysql.ExecuteSql(sql);
                }
                break;
            case "ToSp":
                //商品资料
                dt = mssql.ExecuteDt("select spid,spbh,spmch,zjm,dw,shpgg,shengccj,pizhwh,leibie from spkfk");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sql = @"insert into spkfk(spid,spbh,spmch,zjm,dw,shpgg,shengccj,pizhwh,leibie)"
                        + "values"
                        + "('" + dt.Rows[i][0].ToString() + "','" + dt.Rows[i][1].ToString() + "','" + dt.Rows[i][2].ToString() + "','" + dt.Rows[i][3].ToString() + "','" + dt.Rows[i][4].ToString() + "','" + dt.Rows[i][5].ToString() + "','" + dt.Rows[i][6].ToString() + "','" + dt.Rows[i][7].ToString() + "','" + dt.Rows[i][8].ToString() + "')";
                    mysql.ExecuteSql(sql);
                }
                break;
            case "ToRk":
                //入库
                dt = mssql.ExecuteDt("select plh,spid,djbh,rq,dwbh,pihao,pici,rkshl,zhy from spls_rk where djbh like 'JHA%'");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sql = @"insert into spls_rk(plh,spid,djbh,rq,dwbh,pihao,pici,rkshl,zhy)"
                        + "values"
                        + "('" + dt.Rows[i][0].ToString() + "','" + dt.Rows[i][1].ToString() + "','" + dt.Rows[i][2].ToString() + "','" + dt.Rows[i][3].ToString() + "','" + dt.Rows[i][4].ToString() + "','" + dt.Rows[i][5].ToString() + "','" + dt.Rows[i][6].ToString() + "','" + dt.Rows[i][7].ToString() + "','" + dt.Rows[i][8].ToString() + "')";
                    mysql.ExecuteSql(sql);
                }
                break;
            case"ToCk":
                //出库
                dt = mssql.ExecuteDt("select plh,spid,djbh,rq,dwbh,pihao,pici,chkshl,zhy from spls_ck where djbh like 'XSA%'");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sql = @"insert into spls_ck(plh,spid,djbh,rq,dwbh,pihao,pici,chkshl,zhy)"
                        + "values"
                        + "('" + dt.Rows[i][0].ToString() + "','" + dt.Rows[i][1].ToString() + "','" + dt.Rows[i][2].ToString() + "','" + dt.Rows[i][3].ToString() + "','" + dt.Rows[i][4].ToString() + "','" + dt.Rows[i][5].ToString() + "','" + dt.Rows[i][6].ToString() + "','" + dt.Rows[i][7].ToString() + "','" + dt.Rows[i][8].ToString() + "')";
                    mysql.ExecuteSql(sql);
                }
                break;
        }
        msg.Text = "成功"+id;
        

    }
     */

}